package jp.sourceforge.talisman.csvio.builder;

/*
 * $Id: AbstractCsvLineBuilder.java,v 1.1 2009/09/12 05:06:11 weiwei Exp $
 */

import java.util.List;

import jp.sourceforge.talisman.csvio.CsvIOSetting;
import jp.sourceforge.talisman.csvio.CsvLine;
import jp.sourceforge.talisman.csvio.CsvLineBuilder;

/**
 * 
 * @author tamada
 * @version $Revision: 1.1 $ $Date: 2009/09/12 05:06:11 $
 */
abstract class AbstractCsvLineBuilder implements CsvLineBuilder{
    private CsvIOSetting setting;

    public AbstractCsvLineBuilder(){
        this(new CsvIOSetting());
    }

    public AbstractCsvLineBuilder(CsvIOSetting setting){
        this.setting = setting;
    }

    public CsvIOSetting getSetting(){
        return setting;
    }

    public void setSetting(CsvIOSetting setting){
        this.setting = setting;
    }

    public CsvLine buildCsvLine(String line){
        List<String> strings = splitToTokens(line);
    
        CsvLine csvline = new CsvLine();
        for(String string: strings){
            csvline.addValue(string);
        }
    
        return csvline;
    }

    protected abstract List<String> splitToTokens(String line);
}
